package com.common.dto;

import com.common.consts.CommonRespCode;
import com.common.exception.CommonException;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

/**
 * @author: zhaojd1604@gmail.com
 * @date: 2019-01-02 16:42
 * @description: 基础响应类
 * @since: V0.0.1
 */
@Setter
@Getter
public class BaseResp implements Serializable {

    /**
     * 返回码
     */
    private Integer code;
    /**
     * 返回码对应的信息
     */
    private String message;

    public BaseResp() {
        this.code = CommonRespCode.SUCCESS.getCode();
        this.message = CommonRespCode.SUCCESS.getMessage();
    }

    public BaseResp(CommonRespCode commonRespCode) {
        this.code = commonRespCode.getCode();
        this.message = commonRespCode.getMessage();
    }

    public BaseResp(CommonException commonException) {
        this.code = commonException.getResponseCode();
        this.message = commonException.getMessage();
    }
}